package MyDAO;

import java.sql.*;
import MyDAO.ConnectionDao;

public class clientDao 
{
	String Name;
	String E_mail;
	String Address;
	int Phone_number;
	int Preferred_Calling_time;
	String Client_id;
	
	public clientDao()throws SQLException
	{
	  try
		 {
		 	ConnectionDao.createConnection();
		 }
	 catch(Exception e)
	     {
			System.out.println("Connection not establish"+e.getStackTrace());
		 }
	}
	public void insertCLientRecord()throws SQLException
	{
		String insertQuery;
		insertQuery="insert into client values("+"'Client_id'"+","+"'Name'"+","+"'Address'"+","+Phone_number+","+Preferred_Calling_time+")";
		try
		  {
		    ConnectionDao.pstmt=ConnectionDao.conn.prepareStatement("insertQuery");
		  }
		catch(Exception e)
		  {
			System.out.println("Record not inserted"+e.getStackTrace());
		  }
	}
	
	public void searchClientRecord(String clid)throws SQLException
	{
		String clientid;
		boolean flag=false;
		while(ConnectionDao.resultset.next())
		{
			clientid=""+ConnectionDao.resultset.getInt(Client_id);
			if (clientid.equals(clid))
		      {
			     Name=ConnectionDao.resultset.getString("Name");
		    	 Phone_number=ConnectionDao.resultset.getInt("Phone_number");
			     System.out.println("Name:"+Name);
			     System.out.println("Mobile number"+Phone_number);
			     flag=true;
			     break;
		      }
		
	     }
		
		if (flag==true)
			System.out.println("Record Found");
		else
			System.out.println("Record not found");
	}	
}
